<?
require_once("lib/php/Singleton.php");

class Authentication extends Singleton {
	public static function getInstance() {
		return parent::getInstance(__CLASS__);
	}

	private $isLoggedIn_;
	
	protected function __construct() {
		session_start();
		
		if (isset($_SESSION["isLoggedIn"])) {
			$this->isLoggedIn_ = $_SESSION["isLoggedIn"];
		} else {
			$this->isLoggedIn_ = false;
		}
	}
	
	public function login($pw) {
		require("ericdingle/conf/password.php");
		
		if (md5($pw) == $PASSWORD) {
			$this->isLoggedIn_ = $_SESSION["isLoggedIn"] = true;
			return true;
		} else {
			return false;
		}
	}
	
	public function logout() {
		$this->isLoggedIn_ = false;
		unset($_SESSION["isLoggedIn"]);
	}
	
	public function isLoggedIn() {
		return $this->isLoggedIn_;
	}
}
?>
